package cn.chenc.framework.demo.controller;

import cn.chenc.framework.core.model.response.AjaxResult;
import cn.chenc.framework.demo.entity.UserEntity;
import cn.chenc.framework.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 　@description: TODO
 * 　@author secret
 * 　@date 2021/5/14 16:04
 *
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/all")
    public List<UserEntity> queryAll() {
        return userService.queryAll();
    }

    @GetMapping("/list")
    public Page<UserEntity> queryUserPageList(UserEntity userEntity){
        return userService.queryUserPageList(userEntity);
    }

    @PostMapping
    public AjaxResult insertUser(@RequestBody UserEntity userEntity){
        userService.insertUser(userEntity);
        return AjaxResult.success();
    }

    @GetMapping("/baseApiPage")
    public Page<UserEntity> baseApiPage(UserEntity userEntity) throws Exception {
        return userService.baseApiPage(userEntity);
    }

}
